import { Application } from 'egg';

export default (app: Application) => {
  const mongoose = app.mongoose;
  const schema = new mongoose.Schema({
    // 标题
    title: {
      type: String,
      trim: true,
      required: true,
    },
    // 副标题
    subhead: {
      type: String,
      required: false,
    },
    // 说明
    des: {
      type: String,
      trim: true,
      required: true,
    },
    // 图标url
    icon: {
      type: String,
      required: true,
    },
    // 类型：['homeCenter',‘housekeeping’]
    channel: {
      type: String,
      required: true,
      default: 'homeCenter',
    },
    // 链接类型 ['app', 'h5']
    uriType: {
      type: String,
      enum: [ 'app', 'h5' ],
      required: true,
      default: 'app',
    },
    // 链接
    uri: {
      type: String,
      required: true,
    },
    // 路由方式 ['tab', 'page']
    routerType: {
      type: String,
      enum: [ 'tab', 'page' ],
      default: 'page',
      required: true,
    },
    // 排序(不能重复)
    sort: {
      type: Number,
      required: true,
    },
    // 是否显示hot图标
    isHot: {
      type: Boolean,
      required: true,
      default: false,
    },
    width: Number,
    height: Number,
    // 状态
    status: {
      type: Number,
      required: true,
      default: 0, // 0: 上架, 1: 下架, 2: 删除
    },
  });
  return mongoose.model('Quikemenu', schema, 'quikemenu');
};
